﻿using System.Collections;
using Eneta.Portal.Forum.Core.Domain.Entities;

namespace Eneta.Portal.Forum.Core.Domain.Collections
{
    public class GroupCollection : CollectionBase
    {
        // Methods
        public int Add(Group group)
        {
            return List.Add(group);
        }

        public Group Find(int id)
        {
            foreach (Group group in List)
            {
                if (group.Id == id)
                {
                    return group;
                }
            }
            return null;
        }

        public virtual void Remove(Group group)
        {
            List.Remove(group);
        }

        public override string ToString()
        {
            string str = string.Empty;
            for (int i = 0; i < List.Count; i++)
            {
                Group group = this[i];
                str = str + group.Id.ToString();
                if (i < (List.Count - 1))
                {
                    str = str + ";";
                }
            }
            return str;
        }

        // Properties
        public Group this[int index]
        {
            get
            {
                return (List[index] as Group);
            }
            set
            {
                List[index] = value;
            }
        }
    }
}